﻿(function (_this) {
    
    _this.Url = (function () {
        var __this = new Object();
        var config = {
            ourl: window.location.href,
            href: "",
            params: {},
            pound: ""
        };
        var init = function () {
            var str = config.ourl;
            config.params = {};
            config.href = config.ourl;
            config.pound = "";
            var index = str.indexOf("#");
            if (index > 0) {
                config.pound = str.substr(index);
                str = str.substring(0, index);
            }
            index = str.indexOf("?");
            if (index > 0) {
                this.href = str.substring(0, index);
                str = str.substr(index + 1);
                var parts = str.split("&");
                for (var i = 0; i < parts.length; i++) {
                    if (parts[i] != "") {
                        var kv = parts[i].split("=");
                        config.params[kv[0]] = kv[1];
                    }
                }
            }
        };
        __this.parentPath = function(){//设置请求连接头  域名+项目文件名
            return window.location.origin + '/' + window.location.pathname.split('/')[1];
        };
        __this.get = function (key) {
            return config.params[key] ? config.params[key] : '';
        };
        init();
        return __this;
    })();
})(vui);
